<template>
  <div class="ym-header-right">
    <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect"
      background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
      <el-menu-item index="1">锁屏</el-menu-item>
      <el-menu-item index="2">文档</el-menu-item>
      <el-submenu index="3">
        <template slot="title">
          <img :src="loginUser.imgUrl" style="width: 40px;height: 40px;border-radius: 40px;"/>
          {{loginUser.nickname}}
        </template>
        <el-menu-item index="3-1">个人中心</el-menu-item>
        <el-menu-item index="3-2">修改密码</el-menu-item>
        <el-menu-item index="3-3" @click="logout">退出登录</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
  import {
    removeToken,
    removeLoginUser,
    getLoginUser
  } from '@/util/storage.js'
  export default {
    data() {
      return {
        activeIndex: '0',
        activeIndex2: '0',
        loginUser: getLoginUser()
      }
    },
    methods: {
      handleSelect() {},
      logout() {
        removeToken()
        removeLoginUser()
        this.$router.push('/')
      }
    }
  }
</script>

<style scoped>
  .ym-header-right {
    float: right;
    margin-right: -20px;
  }
</style>
